// ==UserScript==
// @name         189云助手
// @namespace    http://your.homepage/
// @version      0.1
// @description  enter something useful
// @author       You
// @match        http://cloud.189.cn/main.action
// @grant        none
// @icon          http://cloud.189.cn/logo.ico
// ==/UserScript==

/**

(
     ($)->
         getData = ()->
              url = "http://cloud.189.cn/listMyDownloads.action?type=1&pageNum=1&pageSize=500&noCache=0.5989990714006126"
              $.getJSON url,(data)->
                  $tasks = $(".task-item")
                  index = 0
                  for item in data.data
                      process =  parseFloat(item.taskProccess)/100
                      speed = parseFloat(item.taskDSpeed)/1000
                      text =  "#{speed} kb/s (#{process}%)"
                      $($tasks[index]).find(".icon-state").text text
                      index++
                     
         window.setInterval getData,1000
)(jQuery)

**/

(function($) {
  var getData;
  getData = function() {
    var url;
    url = "http://cloud.189.cn/listMyDownloads.action?type=1&pageNum=1&pageSize=500&noCache=0.5989990714006126";
    return $.getJSON(url, function(data) {
      var $tasks, index, item, process, speed, text, _i, _len, _ref, _results;
      $tasks = $(".task-item");
      index = 0;
      _ref = data.data;
      _results = [];
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        item = _ref[_i];
        process = parseFloat(item.taskProccess) / 100;
        speed = parseFloat(item.taskDSpeed) / 1000;
        text = "" + speed + " kb/s (" + process + "%)";
        $($tasks[index]).find(".icon-state").text(text);
        _results.push(index++);
      }
      return _results;
    });
  };
  return window.setInterval(getData, 3000);
})(jQuery);